/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package aspect.example;
import aspect.entity.Entity;
import aspect.entity.behavior.Behavior;
import aspect.entity.behavior.TimeToLive;
import aspect.physics.Motion;
import aspect.physics.Time;
import aspect.render.Billboard;
import aspect.render.Material;
import aspect.render.ViewModel;
import aspect.render.shader.Shader;
import aspect.render.shader.ShaderProgram;
import static aspect.resources.Resources.ellipse;
import static aspect.resources.Resources.loadShader;
import aspect.util.Color;
import aspect.util.Vector3;
import java.io.File;
import org.lwjgl.opengl.GL11;
/**
*
* @author MillerV
*/
public class Trail extends Entity {
public static ShaderProgram shader;
public ViewModel model;
public Trail(Vector3 pos, Vector3 vel, final Frigate source) {
if (shader == null) {
Shader vert = loadShader(new File("shaders/test.vert"), Shader.Type.VERTEX);
Shader frag = loadShader(new File("shaders/test.frag"), Shader.Type.FRAGMENT);
shader = new ShaderProgram(vert, frag);
}
Material mtl = new Material(shader);
model = ellipse(mtl, 2.0f, 2.0f, 20);
addBehavior(new Billboard(model));
addBehavior(new Motion(vel, Vector3.zero()));
addBehavior(new TimeToLive(2.0f));
addBehavior(new Behavior() {
@Override
public void update() {
float f = 0.2f;
if (source.thrust == 0.0f) {
f = 0.01f;
}
model.transform.scale = model.transform.scale.times((float)Math.pow(f, Time.deltaTime()));
}
});
transform.position = pos;
}
@Override
public void render() {
GL11.glDepthMask(false);
super.render();
GL11.glDepthMask(true);
}
}